/******************************************************************************

  Copyright (C), 2001-2011, Hisilicon Tech. Co., Ltd.

 ******************************************************************************
  File Name     : hi_api_ddal.h
  Version       : Initial Draft
  Author        : Hisilicon multimedia software group
  Created       : 2015/06/8
  Description   : LED.c header file
  History       :
  1.Date        : 2015/06/8
    Author      : thomas
    Modification: Created file

******************************************************************************/

#ifndef __HI_LED_H__
#define __HI_LED_H__

#define OSDRV_MODULE_VERSION_STRING "HISI_LED @Hi3518v100R001"

/* define device name */
#define HILED_DEVICE_NAME "Hi_LED"

#define ST_LED_NUM  6

#define HI_LED_SET_CFG  0x0

#define ST_LED_INPUT    0x0
#define ST_LED_OUTPUT   0x1

#define ST_LED_OFF  0x0
#define ST_LED_ON   0x1

#define ST_LED_SD    0x0
#define ST_LED_ALARM    0x1
#define ST_LED_LOCK    0x2
#define ST_LED_SMS    0x3
#define ST_LED_VIDEO    0x4
#define ST_LED_GSM    0x5

/**
*** | 31-30 | 29--25 | 24 -- 20 | 19 -- 15 | 14 -- 10 | 9 -- 5 | 4--0 |
***  reserve      cfg5          cfg4        cfg3           cfg2        cfg1     cfg0
*** 
*** cfg0-cfg5 correspond to configuration of led0-led5
*** each configuration has 5 bits:
***                         bit4:   input/output
***                         bit3:   on/off
***                         bit2-bit0:flash frequence in 500ms
**/
#define GEN_CFG(dir, ison, freq, index)                 ( ( dir << 4 | ison << 3 | freq ) << ( index * 5 ) )
#define GEN_ST_LED_CFG(cfg, dir, ison, freq, index)     ( (( cfg ) & (~( 0x1F << ( index * 5 ) ))) | GEN_CFG( dir,ison,freq,index ) )

#define GET_CFG(cfg, idx)               ( ( cfg >> ( idx * 5 ) ) & 0x1F )
#define GET_ST_LED_DIR(cfg, idx)        ( ( GET_CFG(cfg,idx) ) >> 4 )
#define GET_ST_LED_ISON(cfg, idx)       ( ( GET_CFG(cfg,idx) >> 3 ) & 0x1 )        
#define GET_ST_LED_FREQ(cfg, idx)       ( GET_CFG(cfg,idx) & 0x7 )

typedef struct LED_CFG
{
    char dir;
    char ison;
    char freq;
}LED_CFG_STRU;
#endif /* End of #ifndef __HI_LED_H__*/

